package com.dense.kuiniu.floatcabinet.mvp.ui.adapter;

import android.view.View;
import android.widget.ImageView;

import androidx.annotation.NonNull;

import com.dense.kuiniu.floatcabinet.R;
import com.jess.arms.http.imageloader.ImageLoader;
import com.jess.arms.utils.ArmsUtils;
import com.zhpan.bannerview.BaseBannerAdapter;
import com.zhpan.bannerview.BaseViewHolder;

/**
 * @author Administrator
 * @date 2020/9/29
 */
public class BannerAdapter extends BaseBannerAdapter<Integer, BannerAdapter.NetViewHolder> {


    @Override
    protected void onBind(NetViewHolder holder, Integer resourceId, int position, int pageSize) {
        holder.bindData(resourceId, position, pageSize);
    }

    @Override
    public NetViewHolder createViewHolder(View itemView, int viewType) {
        return new NetViewHolder(itemView);
    }

    @Override
    public int getLayoutId(int viewType) {
        return R.layout.item_banner;
    }

    public static class NetViewHolder extends BaseViewHolder<Integer> {

        private ImageLoader mImageLoader;
        public NetViewHolder( @NonNull View itemView) {
            super(itemView);
            mImageLoader = ArmsUtils.obtainAppComponentFromContext(itemView.getContext()).imageLoader();

        }

        @Override
        public void bindData(Integer resourceId, int position, int pageSize) {
            ImageView imageView = findView(R.id.imageView);
            imageView.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {

                }
            });
            imageView.setBackgroundResource(R.mipmap.bg_test_banner);
//            mImageLoader.loadImage(itemView.getContext(),
//                    ImageConfigImpl
//                            .builder()
//                            .url(data.getAvatarUrl())
//                            .imageView(imageView)
//                            .build());
        }
    }
}